package com.example.mymall.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.mymall.entity.ShopcartEntity;
import com.example.mymall.entity.UserGoodsCartVO;
import com.example.mymall.repository.ShopcartService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.mymall.repository.impl.ShopcartServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author <a href="https://srpihot.site">Srpihot</a>
 * @since 2021-10-06
 */
@RestController
@RequestMapping("/api/shopcart/")
public class ShopcartController {

    private ShopcartServiceImpl shopcartService;

    @RequestMapping(value = "/pageCart", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public IPage<UserGoodsCartVO> pageCartDetail(int currentPage, int pageSize){
        System.out.println("pre");
        if(shopcartService.getCartDetailAll(currentPage,pageSize) == null){
            System.out.println("is null");
        }else {
            System.out.println("not null");
        }
        System.out.println("last");
        return shopcartService.getCartDetailAll(currentPage,pageSize);
    }

    @RequestMapping(value = "/test", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
    @ResponseBody
    public List<UserGoodsCartVO> page(){
        return shopcartService.test();
    }


//    @RequestMapping(value = "/findCart", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
//    @ResponseBody
//    public List<ShopcartEntity> findCart(){
//        System.out.println("hello1");
////        return "hello";
//        return shopcartService.getCart();
//    }

}

